package com.example.singleton.demo.singleton;

import lombok.extern.slf4j.Slf4j;

/**
 * 延迟加载/懒汉模式
 */
@Slf4j
public class SlackerModelSingleton {

    private static SlackerModelSingleton instance;

    private SlackerModelSingleton() {
    }

    public static SlackerModelSingleton getInstance() {
        if (instance == null) {
            synchronized (SlackerModelSingleton.class) {
                if (instance == null) {
                    instance = new SlackerModelSingleton();
                }
            }
        }
        return instance;
    }

    public void doSomeThing() {
        log.info(">>> SlackerModelSingleton do some things");
    }
}
